package com.qingmi.farmer.data.repository.data;

import com.wjjun.base.data.cache.CacheProviders;
import com.wjjun.base.data.db.DBManager;
import com.wjjun.base.data.db.IDBManager;
import com.qingmi.farmer.data.model.UserInfo;
import com.qingmi.farmer.data.repository.api.UserApiRepository;
import com.qingmi.farmer.data.request.LoginByCodeReq;
import com.qingmi.farmer.data.request.LoginReq;
import com.wjjun.base.data.respository.BaseDataRepository;
import com.wjjun.basemvpvm.data.executor.PostExecutionThread;
import com.wjjun.basemvpvm.data.executor.ThreadExecutor;
import com.wjjun.basemvpvm.data.observer.DefaultObserver;

import javax.inject.Inject;

/**
 * 用户相关的数据仓库
 * author Wjjun
 * Created 2018/3/20.
 */

public class UserDataRepository extends BaseDataRepository<UserApiRepository> {

    private IDBManager dbManager;


    @Inject
    public UserDataRepository(UserApiRepository apiRepository, ThreadExecutor threadExecutor,
                              PostExecutionThread postExecutionThread,
                              DBManager dbManager, CacheProviders cacheProviders) {

        super(apiRepository, threadExecutor, postExecutionThread, cacheProviders);
        this.dbManager = dbManager;
    }

    /**
     * 登陆
     */
    public void login(DefaultObserver<UserInfo> observer, LoginReq param) {
        execute(apiRepository.login(param), observer);
    }

    /**
     * 验证码登陆
     */
    public void loginByCode(DefaultObserver<UserInfo> observer, LoginByCodeReq param) {
        execute(apiRepository.loginByCode(param), observer);
    }


}
